<!--
 * @Descripttion: 拼团列表
 * @Author: xiao li
 * @Date: 2020-07-06 12:17:07
 * @LastEditors: xiao li
 * @LastEditTime: 2021-04-28 15:38:25
-->
<template>
    <div>
      <top-nav />
      <div class="page-main">
        <el-table
            v-loading='loading'
          :data="tableData"
          :header-cell-style="{background:'#f5f7fa',color:'#606266'}"
          style="width: 100%">
          <el-table-column
            prop="id"
            label="ID"
            width="180">
          </el-table-column>
          <el-table-column
            prop="name"
            label="商品名"
            width="180">
          </el-table-column>
          <el-table-column
            prop="goods_id"
            label="商品ID">
          </el-table-column>
          <el-table-column
            prop="number"
            label="成团人数">
          </el-table-column>
          <el-table-column
            prop="left_number"
            label="剩余人数">
          </el-table-column>
          <el-table-column
            prop="price"
            label="单价">
          </el-table-column>
          <el-table-column
            prop="collage_status"
            label="状态">
          </el-table-column>
          <el-table-column
            prop='create_time'
            label="创建时间">
              <template slot-scope="scope">
                <div>{{scope.row.create_time | handleTime(1)}}</div>
                <div>{{scope.row.create_time | handleTime(2)}}</div>
              </template>
          </el-table-column>
        </el-table>
        <lb-page
        :batch='false'
        :page='page'
        :pageSize='limit'
        :total='total'
        @handleSizeChange='handleSizeChange'
        @handleCurrentChange='handleCurrentChange'
        >
        </lb-page>
      </div>
    </div>
</template>

<script>
export default {
  data () {
    return {
      loading: false,
      tableData: [],
      page: 1,
      limit: 10,
      total: 0
    }
  },
  created () {
    this.getAssembleList()
  },
  methods: {
    handleSizeChange (val) {
      this.limit = val
      this.handleCurrentChange(1)
    },
    handleCurrentChange (val) {
      this.page = val
      this.getAssembleList()
    },
    getAssembleList () {
      this.loading = true
      let {page, limit} = this
      this.$api.getAssembleRecordList({page, limit}).then(res => {
        this.loading = false
        if (res.code === 200) {
          this.total = res.data.total
          this.tableData = res.data.data
        }
      })
    }
  },
  filters: {
    handleTime (val, type) {
      let time = type === 1 ? moment(val * 1000).format('YYYY-MM-DD') : type === 2 ? moment(val * 1000).format('HH:mm:ss') : moment(val * 1000).format('YYYY-MM-DD HH:mm:ss')
      return time
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
